<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html>
<html>
<head>
<title>回收物管理</title>
<base href="" />
<link rel="Stylesheet" type="text/css" href="/css/Form.css" />
<link href="../../style/css.css" rel="stylesheet" type="text/css" />
<link rel="Stylesheet" type="text/css"
	href="/css/themes/base/jquery.ui.all.css" />
<script type="text/javascript" src="/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	$(function() {
		var role = $("#txtRole").val();

		if (role == "3") {
			$("#btnAdd").hide();
		}
		if (role == "2") {
			$("#btnAdd").hide();
			$("#btnEdit").hide();

		}
	});
	function duihuan() {
		var icount = getCount();
		if (icount == 0) {
			alert('请选择一条数据进行修改！');
			return;
		}
		if (icount > 1) {
			alert('只能同时修改一条数据！');
			return;
		}
		$("#EditFrame")
				.attr(
						"src",
						"/huishouwupin/duihuan?ID="
								+ $(
										"input[type = 'checkbox'][name = 'checkuser']:checked")
										.val());
		$("#EditDialog").dialog({
			bgiframe : true,
			height : 450,
			width : 400,
			modal : true
		});
		$("#EditDialog").dialog("open");
	}
	function shenhe(type) {
		var icount = getCount();
		if (icount == 0) {
			alert("请选择要审核的数据！");
			return false;
		} else {
			if (confirm("确定要审核当前选择的 " + icount + " 条数据吗？")) {
				//执行删除的操作
				var ids = "";
				$("input[type='checkbox'][name='checkuser']:checked").each(
						function() {
							ids += $(this).val() + ",";
						});
				$.post("/huishouwupin/wupinshenhe", {
					ids : ids,type:type
				}, function(data) {
					if (data == "1") {
						alert("操作成功！");

					} else {
						alert("操作失败！");
					}
					window.location.reload();
				});
			} else {
				return;
			}
		}
	}
	
	function getCount() {
		return $("input[type='checkbox'][name='checkuser']:checked").length;
	}
	function closedialog() {
		$("#EditDialog").dialog('close');
	}
</script>
</head>
<body>
	<form id="form1">
		<input type="hidden" id="txtRole"
			value="${user.role}" />
		<div class="position">当前位置 > 回收物管理</div>
		<div>
			<div class="line"></div>
			<div class="search">
				 <input type="button"
					id="btnEdit" value="提交兑换" onclick="duihuan();"
					class="btn_css  submitbg" />&nbsp;
					 <input type="button" value="审核通过"
					onclick="shenhe(1)" class="btn_css  submitbg" />&nbsp;
					 <input type="button" value="审核不通过"
					onclick="shenhe(-1)" class="btn_css  submitbg" />
				</div>
			<table id="gvUser" class="table_list" cellpadding="0">
				<tr>
					<th>选择</th>
					<th>名称</th>
					<th>上门回收时间</th>
					<th>地址</th>
					<th>类型</th>
					<th>回收积分</th>
					<th>捐赠人</th>
					<th>状态</th>
					<th>兑换积分</th>
				</tr>
				<c:forEach items="${list}" varStatus="i" var="item" >
					<tr>
						<td><input type="checkbox" name="checkuser"
								   value=${item.id}></td>
						<td>${item.name}</td>
						<td>${item.onSiteRecycleTime}</td>
						<td>${item.address}</td>
						<td>${item.typeId}</td>
						<td>${item.recyclePoints}</td>
						<td>${item.userId}</td>
						<td>${item.status}</td>
						<td>${item.changePoints}</td>
					</tr>
				</c:forEach>
			</table>
		</div>
		<div id="EditDialog" title="编辑" style="display: none;">
			<iframe id="EditFrame" frameborder="0" width="100%" height="100%"></iframe>
		</div>
	</form>
</body>
</html>
